package com.zenithmind.chat.pojo.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.time.LocalDateTime;

/**
 * 群组关联VO - 遵循单一职责原则
 * 只负责群组关联的视图展示
 * 
 * @author ZenithMind Team
 * @since 2025-01-09
 */
@Data
@Schema(description = "群组关联VO")
public class ChatGroupAssociationVO {

    @Schema(description = "关联ID")
    private String id;

    @Schema(description = "群组ID")
    private String groupId;

    @Schema(description = "群组名称")
    private String groupName;

    @Schema(description = "关联类型")
    private String associationType;

    @Schema(description = "关联类型名称")
    private String associationTypeName;

    @Schema(description = "关联资源ID")
    private String resourceId;

    @Schema(description = "关联资源名称")
    private String resourceName;

    @Schema(description = "关联资源描述")
    private String resourceDescription;

    @Schema(description = "扩展信息")
    private String extraInfo;

    @Schema(description = "状态")
    private Integer status;

    @Schema(description = "创建者ID")
    private String creatorId;

    @Schema(description = "状态文本")
    private String statusText;

    @Schema(description = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;

    @Schema(description = "更新时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime updateTime;

    @Schema(description = "创建人")
    private String createBy;

    @Schema(description = "更新人")
    private String updateBy;

    /**
     * 获取显示名称
     *
     * @return 显示名称
     */
    public String getDisplayName() {
        if (resourceName != null && !resourceName.trim().isEmpty()) {
            return resourceName;
        }
        return associationType + ":" + resourceId;
    }

    /**
     * 获取状态文本
     *
     * @return 状态文本
     */
    public String getStatusText() {
        if (status == null) {
            return "未知";
        }
        return status == 1 ? "有效" : "无效";
    }
}
